package me.shiqiang.im.service;

import me.shiqiang.im.vo.Friend;
import me.shiqiang.im.vo.Group;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.Collection;

/**
 * @author cuishiqiang
 * @date 2018/1/15 下午3:33
 */
@Service
@CacheConfig(cacheNames = "users")
public class UserService {

    @Autowired
    UserClient userClient;

    @Cacheable(key = "'user.groups'+#userId")
    public Collection<Group> getGroups(Long userId){
        return userClient.getGroups(userId);
    }

//    @Cacheable(key = "'user.friends'+#userId")
    public Collection<Friend> getFriends(Long userId) {
        return userClient.getFriends(userId);
    }
}
